{extend name="base/base" /}
{block name="style"}
<style type="text/css">
.layui-table-cell{
     height: auto!important;
     white-space: normal;
}
</style>
{/block}
{block name="content"}
<!-- <script type="text/html" id="switchTpl">

  <input type="checkbox" name="status" value="{{d.status}}" lay-skin="switch" lay-text="开|关" lay-filter="status" id="{{d.id}}" {{ d.status == 1 ? 'checked' : '' }}>
</script> -->
  <div class="layui-form-item layui-form-pane">
  <!--   <div class="layui-inline">
        <div class="demoTable">
          <button class="layui-btn layui-btn-normal" onclick="add()">新增</button>
        </div>
      </div> -->
  <table id="table" lay-filter="table"></table> 
</div>
 <!--  <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  </script> -->
{/block}
{block name="script"}
<script>
layui.use(['table', 'laydate','form'], function(){
  var table = layui.table;
  var laydate = layui.laydate;
  var form = layui.form;
  table.render({
    elem: '#table'
    ,height: 'full-150'
    ,url: '/admin/invest/teamList/' //数据接口
    ,limit:20
    ,page: true //开启分页
    ,id:'reload'
    ,cols: [[ //表头
        {field:'level', title: '等级', width: 200}
        ,{field:'name', title: '等级名称', width: 200,edit: 'text'}
        ,{field:'amount', title: '价格', width: 200,edit: 'text'}
        ,{field:'rate', title: '收益比例', width: 200,edit: 'text'}
    ]]
  }); 
  ///监听单元格编辑
  table.on('edit(table)', function(obj){
    var value = obj.value //得到修改后的值
    ,data = obj.data //得到所在行所有键值
    ,field = obj.field; //得到字段
    var post_data = {
      id:data.id,
      field:field,
      value:value,
       'tyep':1
    };
    $.ajax({
            url:"{:url('admin/invest/editTable')}",
            type:"POST",
            data:post_data,
            success:function(ret){
                if (ret.code == 0) {
                  layer.msg('操作成功');
                  $(".layui-laypage-btn")[0].click();
                }
                if (ret.code == 1) {
                    layer.msg(ret.msg);
                }
            }
        });
  });
});
</script>
{/block}
